#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
	printf("Test_execl...begin\n");

	pid_t id = fork();
	if(id==0)
	{
		sleep(1);
		char* const argv[] = 
		{
			(char*)"ls",
			(char*)"-l",
			(char*)"-a",
			(char*)"--color",
			NULL
		};
		execvp("ls",argv);
		exit(1);
	}
	//父进程
	int status = 0;
	pid_t rid = waitpid(id,&status,0);
	if(rid>0)
	{
		printf("father wait success, child exit code: %d\n",WEXITSTATUS(status));
	}
	printf("Test_execl...end\n");
	return 0;
}
